
local total = achievements.GetValue( "Engineer", "total", 0 )

local oldRate
local function Update()
	local ply = LocalPlayer()
	if ( !ValidEntity( ply ) ) then return end
	if ( total == 50 ) then return end	
	
	local builder = ply:GetNWInt( "Rating.builder" )
	if ( builder > ( oldRate or builder ) ) then
		if ( oldRate != 0 || builder == 1 ) then
			total = math.Clamp( total + ( builder - oldRate ), 0, 50 )
			achievements.Update( "Engineer", total / 50, total .. "/50" )
			achievements.SetValue( "Engineer", "total", total )
		end
	end
	oldRate = builder
end
timer.Create( "Achievements.Engineer", 1, 0, Update )

achievements.Register( "Engineer", "Get rated 'builder' 50 times.", "achievements/engineer", total / 50, total .. "/50" )